﻿<ResourceDictionary
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:doc="http://schemas.firstfloorsoftware.com/documenttoolkit"
    xmlns:i="http://schemas.microsoft.com/expression/2010/interactivity">

    <!-- Default Style for FirstFloor.Documents.Controls.DocumentDataSource -->
    <Style TargetType="doc:DocumentDataSource">
        <Setter Property="Visibility" Value="Collapsed" />
        <Setter Property="IsTabStop" Value="False" />
    </Style>

    <!-- Default Style for FirstFloor.Documents.Controls.DocumentPrinter -->
    <Style TargetType="doc:DocumentPrinter">
        <Setter Property="IsTabStop" Value="False" />
    </Style>

    <!-- Default Style for FirstFloor.Documents.Controls.ThumbnailListBox -->
    <Style TargetType="doc:ThumbnailListBox">
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="doc:ThumbnailListBox">
                    <ListBox x:Name="ListBox" ItemsSource="{Binding DocumentDataSource.DefaultThumbnailCollection, RelativeSource={RelativeSource TemplatedParent}}">
                        <i:Interaction.Behaviors>
                            <doc:PageVirtualizer />
                        </i:Interaction.Behaviors>
                        <ListBox.ItemContainerStyle>
                            <Style TargetType="ListBoxItem">
                                <Setter Property="HorizontalContentAlignment" Value="Stretch" />
                            </Style>
                        </ListBox.ItemContainerStyle>
                        <ListBox.ItemTemplate>
                            <DataTemplate>
                                <StackPanel Margin="4" HorizontalAlignment="Center">
                                    <Border Background="White" BorderBrush="Black" BorderThickness="1">
                                        <Image Source="{Binding FixedPageThumbnail}" />
                                    </Border>
                                    <TextBlock Text="{Binding PageContent.PageNumber}" HorizontalAlignment="Center"/>
                                </StackPanel>
                            </DataTemplate>
                        </ListBox.ItemTemplate>
                    </ListBox>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

    <!-- Default Style for FirstFloor.Documents.Controls.PageNavigator -->
    <Style TargetType="doc:PageNavigator">
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="doc:PageNavigator">
                    <StackPanel x:Name="LayoutRoot" Orientation="Horizontal">
                        <TextBox x:Name="PageIndex" Width="36" TextAlignment="Right" Background="Transparent" BorderBrush="Transparent" VerticalAlignment="Center" />
                        <TextBlock Text="/" VerticalAlignment="Center" Margin="0,0,2,0" />
                        <TextBlock x:Name="PageCount" Width="44" VerticalAlignment="Center" Margin="0,2,0,2" />
                        <Button x:Name="PreviousPage" Padding="10" ToolTipService.ToolTip="Previous page">
                            <Button.Content>
                                <Path Width="8" Height="8" Stretch="Uniform" Data="F1 M 0,-1 L 1,1 L -1,1 Z " Fill="Black" />
                            </Button.Content>
                        </Button>
                        <Button x:Name="NextPage" Padding="10" ToolTipService.ToolTip="Next page">
                            <Button.Content>
                                <Path Width="8" Height="8" Stretch="Uniform" Data="F1 M 0,1 L -1,-1 L 1,-1 Z " Fill="Black" />
                            </Button.Content>
                        </Button>
                    </StackPanel>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

    <!-- Default Style for FirstFloor.Documents.Controls.HistoryNavigator -->
    <Style TargetType="doc:HistoryNavigator">
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="doc:HistoryNavigator">
                    <StackPanel x:Name="LayoutRoot" Orientation="Horizontal">
                        <Button x:Name="Back" Padding="10" ToolTipService.ToolTip="Navigate backward">
                            <Button.Content>
                                <Path Width="8" Height="8" Stretch="Uniform" Data="F1 M -1,0 L 1,-1 L 1,1 Z " Stroke="Black" />
                            </Button.Content>
                        </Button>
                        <Button x:Name="Forward" Padding="10" ToolTipService.ToolTip="Navigate forward">
                            <Button.Content>
                                <Path Width="8" Height="8" Stretch="Uniform" Data="F1 M 1,0 L -1,-1 L -1,1 Z " Stroke="Black" />
                            </Button.Content>
                        </Button>
                    </StackPanel>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

    <!-- Default Style for FirstFloor.Documents.Controls.ViewModePicker -->
    <Style TargetType="doc:ViewModePicker">
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="doc:ViewModePicker">
                    <ComboBox x:Name="Selector">
                        <ComboBox.ItemTemplate>
                            <DataTemplate>
                                <TextBlock Text="{Binding DisplayName}" />
                            </DataTemplate>
                        </ComboBox.ItemTemplate>
                    </ComboBox>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

    <!-- Default Style for FirstFloor.Documents.Controls.FixedPageViewer -->
    <Style TargetType="doc:FixedPageViewer">
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="doc:FixedPageViewer">
                    <Grid x:Name="LayoutRoot">
                        <VisualStateManager.VisualStateGroups>
                            <VisualStateGroup x:Name="PageStates">
                                <VisualState x:Name="PageLoading" />
                                <VisualState x:Name="PageLoaded">
                                    <Storyboard>
                                        <ObjectAnimationUsingKeyFrames Storyboard.TargetName="PagePresenter" Storyboard.TargetProperty="Visibility" Duration="0">
                                            <DiscreteObjectKeyFrame KeyTime="0" Value="Visible"/>
                                        </ObjectAnimationUsingKeyFrames>
                                    </Storyboard>
                                </VisualState>
                                <VisualState x:Name="PageError">
                                    <Storyboard>
                                        <ObjectAnimationUsingKeyFrames Storyboard.TargetName="PageErrorElement" Storyboard.TargetProperty="Visibility" Duration="0">
                                            <DiscreteObjectKeyFrame KeyTime="0" Value="Visible"/>
                                        </ObjectAnimationUsingKeyFrames>
                                    </Storyboard>
                                </VisualState>
                            </VisualStateGroup>
                        </VisualStateManager.VisualStateGroups>
                        <ContentPresenter x:Name="PagePresenter" Content="{TemplateBinding FixedPage}" Visibility="Collapsed" />
                        <Grid x:Name="PageErrorElement" Visibility="Collapsed" Width="{Binding FixedPageSize.Width, RelativeSource={RelativeSource TemplatedParent}}" Height="{Binding FixedPageSize.Height, RelativeSource={RelativeSource TemplatedParent}}">
                            <!-- Provides a formatted error page -->
                            <RichTextBox IsReadOnly="True" BorderThickness="0" TextWrapping="Wrap" Margin="32">
                                <RichTextBox.DataContext>
                                    <doc:VersionInfo />
                                </RichTextBox.DataContext>
                                <Paragraph>
                                    <Run FontSize="32" Foreground="Red" Text="Failed to Render Page" />
                                    <LineBreak />
                                    <LineBreak />
                                    <InlineUIContainer>
                                        <Line X2="1" Stretch="Fill" StrokeThickness="1" Stroke="#CCCCCC" />
                                    </InlineUIContainer>
                                    <LineBreak />
                                    <LineBreak />
                                    <Run FontSize="20" FontStyle="Italic" Foreground="Maroon" Text="{Binding FixedPageError.Message, RelativeSource={RelativeSource TemplatedParent}}" />
                                    <LineBreak />
                                    <LineBreak />
                                    <Run FontSize="12" FontWeight="Bold" Text="Description:" />
                                    <Run FontSize="12" Text="An exception occurred during the rendering of this page. Please review the stacktrace for more information about the error." />
                                    <LineBreak />
                                    <LineBreak />
                                    <Run FontSize="12" FontWeight="Bold" Text="Exception Details:" />
                                    <LineBreak />
                                    <Run FontSize="12" Text="{Binding FixedPageError, RelativeSource={RelativeSource TemplatedParent}}" />
                                    <LineBreak />
                                    <LineBreak />
                                    <InlineUIContainer>
                                        <Line X2="1" Stretch="Fill" StrokeThickness="1" Stroke="#CCCCCC" />
                                    </InlineUIContainer>
                                    <LineBreak />
                                    <LineBreak />
                                    <Run FontSize="12" FontWeight="Bold" Text="Version Information:" />
                                    <Run FontSize="12" Text="{Binding DisplayName}" />
                                </Paragraph>
                            </RichTextBox>
                        </Grid>
                    </Grid>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

    <!-- Default Style for FirstFloor.Documents.Controls.DocumentViewer -->
    <Style TargetType="doc:DocumentViewer">
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="doc:DocumentViewer">
                    <Border Background="{TemplateBinding Background}" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}">
                        <ScrollViewer x:Name="ScrollViewer" Background="Transparent" BorderThickness="0" HorizontalScrollBarVisibility="Auto" VerticalScrollBarVisibility="Auto">
                            <ItemsControl x:Name="Pages">
                                <i:Interaction.Behaviors>
                                    <doc:PageVirtualizer />
                                </i:Interaction.Behaviors>
                                <ItemsControl.ItemTemplate>
                                    <DataTemplate>
                                        <Grid Width="{Binding DesiredPageContainerSize.Width}"
                                          Height="{Binding DesiredPageContainerSize.Height}">
                                            <Border Background="White" BorderBrush="Black" BorderThickness="1" Margin="4" HorizontalAlignment="Center" VerticalAlignment="Center">
                                                <doc:FixedPageViewer FixedPage="{Binding FixedPage}" 
                                                                     FixedPageSize="{Binding FixedPageSize}"
                                                                     FixedPageError="{Binding FixedPageError}"
                                                                     Scale="{Binding DesiredPageScale}">
                                                    <i:Interaction.Behaviors>
                                                        <doc:FixedPageAdorner Annotations="{Binding TextContainer.Annotations}" Selection="{Binding TextContainer.Selection}" />
                                                        <doc:NavigationBehavior TextContainer="{Binding TextContainer}" />
                                                    </i:Interaction.Behaviors>
                                                </doc:FixedPageViewer>
                                            </Border>
                                        </Grid>
                                    </DataTemplate>
                                </ItemsControl.ItemTemplate>
                            </ItemsControl>
                        </ScrollViewer>
                    </Border>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

</ResourceDictionary>

